
package cn.yuxirey.spotsview;

import android.graphics.Color;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * 圆点
 */
public class SpotModel implements Spot, Parcelable {
    private int solid;
    private int borderColor;
    @SpotTypeInt
    private int type;

    public SpotModel() {
        solid = Color.WHITE;
        borderColor = Color.TRANSPARENT;
        type = SpotType.FILL_AND_STROKE;
    }

    public SpotModel(Parcel in) {
        solid = in.readInt();
        borderColor = in.readInt();
        type = in.readInt();
    }

    private SpotModel(Builder builder) {
        setSolid(builder.solid);
        setBorderColor(builder.borderColor);
        type = builder.type;
    }

    public static final Creator<SpotModel> CREATOR = new Creator<SpotModel>() {
        @Override
        public SpotModel createFromParcel(Parcel in) {
            return new SpotModel(in);
        }

        @Override
        public SpotModel[] newArray(int size) {
            return new SpotModel[size];
        }
    };

    @Override
    public int getSolid() {
        return solid;
    }

    public void setSolid(int solid) {
        this.solid = solid;
    }

    @Override
    public int getBorderColor() {
        return borderColor;
    }

    public void setBorderColor(int borderColor) {
        this.borderColor = borderColor;
    }

    @Override
    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public static Builder builder() {
        return new Builder();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(solid);
        dest.writeInt(borderColor);
        dest.writeInt(type);
    }

    public static final class Builder {
        private int solid;
        private int borderColor;
        private int type;

        private Builder() {

        }

        public Builder solid(int val) {
            solid = val;
            return this;
        }

        public Builder borderColor(int val) {
            borderColor = val;
            return this;
        }

        public Builder type(int val) {
            type = val;
            return this;
        }

        public SpotModel build() {
            return new SpotModel(this);
        }
    }
}